<template>
  <div class="my-tag">
    <input 
    v-if="bool === false" 
    v-focus
    @blur="bool = true"
    class="input" 
    type="text" 
    placeholder="输入标签"
    v-model="isInput"
    @keydown.enter="ChangeInput" />
    <div 
    v-else 
    @dblclick="show" 
    class="text">{{ value }}</div>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      bool: true,
      isInput: ''
    };
  },
  methods: {
    show() {
      this.bool = !this.bool
      this.isInput = this.value
    },
    ChangeInput() {
      this.$emit('input', this.isInput)
      this.bool = true
    }
  }
};
</script>

<style lang="less" scoped>
.my-tag {
  cursor: pointer;
  .input {
    appearance: none;
    outline: none;
    border: 1px solid #ccc;
    width: 100px;
    height: 40px;
    box-sizing: border-box;
    padding: 10px;
    color: #666;
    &::placeholder {
      color: #666;
    }
  }
}
</style>